﻿<Window x:Class="FluidKit.Showcase.ElementFlow.Window1"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		Title="ElementFlow - FluidKit"
		Height="600"
		Width="800"
		xmlns:local="clr-namespace:FluidKit.Showcase.ElementFlow"
		xmlns:sys="clr-namespace:System;assembly=mscorlib"
		xmlns:Controls="clr-namespace:FluidKit.Controls;assembly=FluidKit"
		WindowStartupLocation="CenterScreen">
	<Window.Resources>
		<local:StringCollection x:Key="TestDataSource" />

		<LinearGradientBrush x:Key="ReflectionBrush"
							 StartPoint="0,0"
							 EndPoint="0,1">
			<LinearGradientBrush.GradientStops>
				<GradientStop Offset="0"
							  Color="#7FFFFFFF" />
				<GradientStop Offset=".5"
							  Color="Transparent" />
			</LinearGradientBrush.GradientStops>
		</LinearGradientBrush>

		<DataTemplate x:Key="TestDataTemplate"
					  DataType="{x:Type sys:String}">
			<Border x:Name="ElementVisual"
					Background="White"
					Padding="5"
					BorderThickness="5"
					BorderBrush="LightGray"
					Grid.Row="0">
				<Image Source="{Binding}"
					   Stretch="Fill" />
			</Border>
		</DataTemplate>

		<DataTemplate x:Key="TestDataTemplate_Reflection"
					  DataType="{x:Type sys:String}">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition />
					<RowDefinition />
				</Grid.RowDefinitions>

				<Border x:Name="ElementVisual"
						Background="White"
						Padding="5"
						BorderThickness="5"
						BorderBrush="LightGray"
						Grid.Row="0">
					<Image Source="{Binding}"
						   Stretch="Fill" />
				</Border>
				<Rectangle OpacityMask="{StaticResource ReflectionBrush}"
						   Grid.Row="1">
					<Rectangle.Fill>
						<VisualBrush Visual="{Binding ElementName=ElementVisual}"
									 RenderOptions.CachingHint="Cache">
							<VisualBrush.Transform>
								<ScaleTransform ScaleX="1"
												ScaleY="-1"
												CenterX="200"
												CenterY="150" />
							</VisualBrush.Transform>
						</VisualBrush>
					</Rectangle.Fill>
				</Rectangle>
			</Grid>
		</DataTemplate>
	</Window.Resources>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="*" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>

		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="0.5*" />
			<ColumnDefinition Width="0.5*" />
		</Grid.ColumnDefinitions>

		<StackPanel Orientation="Vertical"
					Grid.Row="1"
					Grid.Column="0"
					Margin="5">
			<Label>SelectedIndex</Label>
			<Slider x:Name="_selectedIndexSlider"
					Minimum="0"
					Value="0"
					ValueChanged="ChangeSelectedIndex" />
			<Label>TiltAngle</Label>
			<Slider x:Name="_tiltAngleSlider"
					Minimum="0"
					Maximum="90"
					Value="45" />
			<Label>ItemGap</Label>
			<Slider x:Name="_itemGapSlider"
					Minimum="0.25"
					Maximum="3"
					Value="0.5" />
		</StackPanel>

		<StackPanel Orientation="Vertical"
					Grid.Row="1"
					Grid.Column="1"
					Margin="5">
			<Label>FrontItemGap</Label>
			<Slider x:Name="_frontItemGapSlider"
					Minimum="0"
					Maximum="4.0" />
			<Label>PopoutDistance</Label>
			<Slider x:Name="_popoutDistanceSlider"
					Minimum="-2.0"
					Maximum="2.0" />
			<StackPanel Orientation="Horizontal"
						Margin="0,10,0,0">

				<Button x:Name="_regular"
						Click="AddCard"
						Margin="0,0,10,0">Add Type A</Button>
				<Button x:Name="_alert"
						Click="AddCard"
						Margin="0,0,10,0">Add Type B</Button>
				<Button Click="RemoveCard"
						Margin="0,0,10,0">Remove</Button>
			</StackPanel>
		</StackPanel>

		<ItemsControl x:Name="_itemsControl"
					  Grid.Row="0"
					  Grid.Column="0"
					  Grid.ColumnSpan="2"
					  ItemsSource="{StaticResource TestDataSource}"
					  ItemTemplate="{StaticResource TestDataTemplate_Reflection}">
			<ItemsControl.ItemsPanel>
				<ItemsPanelTemplate>
					<Controls:ElementFlow x:Name="ElementFlow"
										  Focusable="True"
										  TiltAngle="{Binding Value, ElementName=_tiltAngleSlider}"
										  ItemGap="{Binding Value, ElementName=_itemGapSlider}"
										  FrontItemGap="{Binding Value, ElementName=_frontItemGapSlider}"
										  PopoutDistance="{Binding Value, ElementName=_popoutDistanceSlider}"
										  ElementWidth="400"
										  ElementHeight="600"
										  HasReflection="False"
										  Background="Black">
						<Controls:ElementFlow.Camera>
							<PerspectiveCamera FieldOfView="60"
											   Position="0,1,4"
											   LookDirection="0,-1,-4"
											   UpDirection="0,1,0" />
						</Controls:ElementFlow.Camera>
					</Controls:ElementFlow>
				</ItemsPanelTemplate>
			</ItemsControl.ItemsPanel>
		</ItemsControl>

		<TextBlock Text="F12 to switch views"
				   Foreground="White"
				   FontWeight="Bold"
				   VerticalAlignment="Top"
				   HorizontalAlignment="Right"
				   Margin="10"
				   Grid.Row="0"
				   Grid.Column="1" />
	</Grid>
</Window>
